<template>
  <div>
    <br>
    <!--淘汰管理-查询 -->
    <el-form :inline="true" :model="form" class="demo-form-inline">
      <el-form-item label="称重日期">
        <el-date-picker v-model="form.sDate" type="date" style="width: 170px" value-format="YYYY-MM-DD" clearable />-
        <el-date-picker v-model="form.eDate" type="date" style="width: 170px" value-format="YYYY-MM-DD" clearable />
      </el-form-item>
      <el-form-item label="羊只耳号">
        <!-- <el-input v-model="form.Earbugles" placeholder="羊只耳号" clearable /> -->
        <el-select v-model="form.Earbugles" style="width: 190px" clearable>
          <el-option label="全部" :value="0"></el-option>
          <el-option v-for="item in ear" :key="item.id" :label="item.name" :value="item.name" />
        </el-select>
      </el-form-item>
      <el-form-item label="淘汰原因">
        <el-select v-model="form.OustCause" style="width: 190px" clearable>
          <el-option label="全部" :value="0"></el-option>
          <el-option v-for="item in OustCauseList" :key="item.value" :label="item.name" :value="item.value" />
        </el-select>
      </el-form-item>
      <el-form-item label="是否离场">
        <el-select v-model="form.Lingchatan" style="width: 190px" clearable>
          <el-option label="全部" :value="0"></el-option>
          <el-option v-for="item in LingchatanList" :key="item.value" :label="item.name" :value="item.value" />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="danger" @click="GetOustInfo">查询</el-button>
        <el-button>重置</el-button>
      </el-form-item>
    </el-form>
    <el-divider />
    <div>
      <el-button type="danger" size="large" @click="OpenVisible" :icon="Plus">新增</el-button>
      <el-button type="danger" size="large" @click="BatchDel()" :icon="Delete">删除</el-button>
      <el-button type="danger" size="large" @click="BatchTrue()" :icon="Stamp">审核</el-button>
      <el-button type="danger" size="large" @click="BatchFalse()" :icon="Stamp">重新审核</el-button>
    </div>
    <br>
    <div>
      <div v-if="TagBool">
        <el-tag style="width:1920px;color: black;height: 50px;" type="danger" :iocn="Delete">
          <spna style="font-size: 15px">
            <Warning style="width: 1em; height: 1em; margin-right: 8px" color="red" />
            <span style="margin-right: 1800px">已选择 {{ TagCount }} 项</span>
          </spna>
        </el-tag>
      </div>
      <div v-else>
        <el-tag style="width:1920px;color: black;height: 50px;" type="success" :iocn="Delete">
          <spna style="font-size: 15px">
            <SuccessFilled style="width: 1em; height: 1em; margin-right: 8px" color="green" />
            <span style="margin-right: 1800px">已选择 {{ TagCount }} 项</span>
          </spna>
        </el-tag>
      </div>
    </div>
    <br>
    <!--淘汰管理-列表 -->
    <el-table :data="OustManageList" stripe style="width: 100%" border @selection-change="handleSelectionChange">
      <el-table-column type="selection" align="center" />
      <el-table-column label="序号" :fixed="true">
        <template v-slot="a">
          <span>{{ a.$index + (page.pageIndex - 1) * page.pageSize + 1 }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="ExamineType" label="审核状态" width="110px" :fixed="true">
        <template v-slot="scope">
          <el-tag type="success" v-if="scope.row.ExamineType == true">审核通过</el-tag>
          <el-tag type="danger" v-else-if="scope.row.ExamineType == false">未审核</el-tag>
        </template>
      </el-table-column>
      <el-table-column prop="OustTime" label="淘汰日期↓" width="110px">
        <template v-slot="scope">
          <span>{{
            scope.row.OustTime
            ? scope.row.OustTime.replace("T", " ").substring(0, 10)
            : null
          }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="Earbugles" label="羊只耳号" width="110px" />
      <el-table-column prop="OustCause" label="淘汰原因" width="110px">
        <template v-slot="data">
          <span v-if="data.row.OustCause == 1">空胎</span>
          <span v-else-if="data.row.OustCause == 2">其他</span>
          <span v-else-if="data.row.OustCause == 3">老龄</span>
          <span v-else-if="data.row.OustCause == 4">屡配不孕</span>
          <span v-else-if="data.row.OustCause == 5">习惯性流产</span>
          <span v-else-if="data.row.OustCause == 6">子宫脱</span>
          <span v-else-if="data.row.OustCause == 7">子宫炎</span>
          <span v-else-if="data.row.OustCause == 8">肥胖</span>
          <span v-else-if="data.row.OustCause == 9">消瘦</span>
          <span v-else-if="data.row.OustCause == 10">精液质量差</span>
          <span v-else-if="data.row.OustCause == 11">拒配</span>
          <span v-else>无乳</span>
        </template>
      </el-table-column>
      <el-table-column prop="Lingchatan" label="是否离场" width="110px">
        <template v-slot="data">
          <span v-if="data.row.Lingchatan == 1">已离场</span>
          <span v-else-if="data.row.Lingchatan == 2">在场</span>
        </template>
      </el-table-column>
      <el-table-column prop="Dispose" label="处理措施" width="110px">
        <template v-slot="data">
          <span v-if="data.row.Dispose == 1">销售</span>
          <span v-else-if="data.row.Dispose == 2">屠宰</span>
          <span v-else-if="data.row.Dispose == 3">无害化处理</span>
        </template>
      </el-table-column>
      <el-table-column prop="Breed" label="品种" width="110px">
        <template v-slot="data">
          <span v-if="data.row.Breed == 1">杜泊</span>
          <span v-else-if="data.row.Breed == 2">澳洲白 </span>
          <span v-else-if="data.row.Breed == 3">萨福克</span>
          <span v-else-if="data.row.Breed == 4">杜湖</span>
          <span v-else-if="data.row.Breed == 5">杜杜湖</span>
          <span v-else-if="data.row.Breed == 6">萨杜湖</span>
          <span v-else-if="data.row.Breed == 7">澳湖</span>
          <span v-else-if="data.row.Breed == 8">湖羊</span>
          <span v-else>澳杜湖</span>
        </template>
      </el-table-column>
      <el-table-column prop="Sex" label="性别" width="110px">
        <template v-slot="data">
          <span v-if="data.row.Sex == 1">公 </span>
          <span v-else>母</span>
        </template>
      </el-table-column>
      <el-table-column prop="ReproductiveState" label="繁殖状态" width="110px">
        <template v-slot="scope">
          <span v-if="scope.row.ReproductiveState==1">后备空怀</span>
          <span v-if="scope.row.ReproductiveState==2">返情空怀</span>
          <span v-if="scope.row.ReproductiveState==3">未孕空怀</span>
          <span v-if="scope.row.ReproductiveState==4">流产空怀</span>
          <span v-if="scope.row.ReproductiveState==5">空胎空怀</span>
          <span v-if="scope.row.ReproductiveState==6">断奶空怀</span>
          <span v-if="scope.row.ReproductiveState==7">妊娠</span>
          <span v-if="scope.row.ReproductiveState==8">哺乳</span>
        </template>
      </el-table-column>
      <el-table-column prop="OustMonth" label="淘汰月龄" width="110px" >
        <template v-slot="a">
              <span v-if="a.row.OustDay/30> 1">
                {{Number(a.row.OustDay/30).toFixed(0)}}
              </span>  
              <span v-else>0</span>  
          </template>  
      </el-table-column>
      <el-table-column prop="OustDay" label="淘汰日龄" width="110px" />
      <el-table-column prop="OustDorm" label="淘汰栋舍" width="110px" />
      <el-table-column prop="OustColumns" label="淘汰栏位" width="110px" />
       <el-table-column prop="CreateBy" label="创建人" width="110px" />
        <el-table-column prop="CreateDate" label="创建时间" width="110px">
          <template v-slot="scope">
            <span>{{
              scope.row.CreateDate
                ? scope.row.CreateDate.replace("T", " ").substring(0, 19)
                : null
            }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="UpdateBy" label="修改人" width="110px" />
        <el-table-column prop="UpdateDate" label="修改时间" width="110px">
          <template v-slot="scope">
            <span>{{
              scope.row.UpdateDate
                ? scope.row.UpdateDate.replace("T", " ").substring(0, 19)
                : null
            }}</span>
          </template>
        </el-table-column>
      <el-table-column prop="ReviewBy" label="复核人" width="110px" />
      <el-table-column prop="ReviewDate" label="复核时间" width="110px">
        <template v-slot="scope">
          <span>{{ scope.row.ReviewDate ? scope.row.ReviewDate.replace("T", " ").substring(0, 19) : null }} </span>
        </template>
      </el-table-column>
      <el-table-column prop="DocumentCord" label="单据号" width="110px" />
      <el-table-column fixed="right" width="110px" label="操作">
        <template v-slot="scope">
          <span v-if="scope.row.ExamineType == false">
            <el-link type="primary" @click="Del(scope.row.OMId)">删除</el-link>&nbsp;
            <el-link type="primary" @click="UpdInfo(scope.row.OMId)">修改</el-link>
          </span>
          <span v-else>
            <el-link type="info" disabled>审核完毕</el-link>
          </span>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <div class="demo-pagination-block">
      <el-pagination v-model:current-page="page.pageIndex" v-model:page-size="page.pageSize"
        :page-sizes="[10, 20, 30, 50]" :background="true" layout="total, sizes, prev, pager, next, jumper"
        :total="page.totalCount" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
    </div>
    <!-- 新增行 -->
    <el-dialog v-model="dialogTableVisible" title="淘汰管理" width="80%" style="height: 80%;" :before-close="NewUpdate">
      <div>
        淘汰日期:<el-date-picker v-model="OustInfo.OustTime" type="date" value-format="YYYY-MM-DD" />
        &nbsp;&nbsp;&nbsp;&nbsp;
        羊只类型:<el-radio-group v-model="OustInfo.SheepTypeId"  style="width: 230px;" >
                          <el-radio :value="1" size="large">种公</el-radio>
                          <el-radio :value="2" size="large">种母</el-radio>
                          <el-radio :value="3" size="large">后裔</el-radio>
                </el-radio-group>
        &nbsp;&nbsp;
        单据号:<el-input v-model="OustInfo.DocumentCord" style="width: 220px;" ></el-input>
        <br><br>
        <div>
            <el-button type="danger" size="default" @click="addOust" :icon="Plus"
                v-if="OustInfo.OMId == 0">新增</el-button>
            <el-button type="danger" size="default" @click="addOust" :icon="DocumentChecked"
                v-else>保存</el-button>
              <el-button type="danger" disabled v-show="OustInfo.OMId == 0">保存</el-button> 
              <el-button type="danger" disabled v-show="OustInfo.OMId == 0">撤销</el-button> 
              <el-button type="danger" disabled v-show="OustInfo.OMId == 0">删除</el-button> 
        </div>
        <br><br>
        <el-table :data="rowList" style="width:100%" border>
          <el-table-column prop="Earbugles" label="耳号" >
              <span>
                  <el-select v-model="OustInfo.Earbugles" @change="AddEar" clearable>      
                    <el-option
                      v-for="item in ear"
                      :key="item.id"
                      :label="item.name"
                      :value="item.name"
                    />
                  </el-select>
              </span>
          </el-table-column>
            <el-table-column prop="OustCause" label="淘汰原因">
              <span>
                <el-select v-model="OustInfo.OustCause" placeholder="请选择" width="180px"  clearable>
                      <el-option v-for="item in OustCauseList" :key="item.value" :label="item.name" :value="item.value" clear />
                  </el-select>
              </span>
          </el-table-column>
          <el-table-column prop="Breed" label="品种">
              <span>
                  <el-select v-model="OustInfo.Breed" clearable>
                    <el-option v-for="item in BreedList" :key="item.value" :label="item.name" :value="item.value" />
                  </el-select>
              </span>
          </el-table-column>
          <el-table-column prop="OustDorm" label="当前栋舍">
                <span>
                    <el-select v-model="OustInfo.OustDorm" placeholder="请选择" clearable
                        @change="GetField()">
                        <el-option v-for="item in Cottage" :key="item.Id" :label="item.Name"
                            :value="item.Name" />
                    </el-select>
                </span>
            </el-table-column>
            <el-table-column prop="OustColumns" label="当前栏位">
                <span>
                    <el-select v-model="OustInfo.OustColumns" placeholder="请选择" clearable>
                        <el-option v-for="item in Field" :key="item.Id" :label="item.Name" :value="item.Name" />
                    </el-select>
                </span>
            </el-table-column>

           <el-table-column prop="Lingchatan" label="离场状态">
              <span>
                   <el-select v-model="OustInfo.Lingchatan"  clearable>
                    <el-option v-for="item in LingchatanList" :key="item.value" :label="item.name" :value="item.value" />
                  </el-select>
              </span>
          </el-table-column>
           <el-table-column prop="Dispose" label="处理措施">
              <span>
                  <el-select v-model="OustInfo.Dispose" placeholder="请选择" clearable>
                      <el-option v-for="item in DisposeList" :key="item.value" :label="item.name" :value="item.value" />
                  </el-select>
              </span>
          </el-table-column>
        </el-table>
      </div> 
    </el-dialog>
  </div>
</template>
<script setup lang="ts">
import http from '@/http'
import {  ref, computed, reactive, inject, onMounted } from "vue";
import type { AxiosStatic } from "axios";
import { get } from "@vueuse/core";
import { ElMessage, ElMessageBox } from "element-plus";
import { Plus, Search, Delete, Stamp, DocumentChecked, Back, Warning, SuccessFilled } from '@element-plus/icons-vue'
const axios = inject("axios") as AxiosStatic;
const refs = ref([
  { OMId: "" }
])

//计算日期之间的天数
const DateDiffer = (Date_end: any) => {
    //date1结束时间
    let date1 = new Date(Date_end);
    //date2当前时间
    let date2 = new Date();
    // date1 = new Date(date1.getFullYear(), date1.getMonth(), date1.getDate());
    // date2 = new Date(date2.getFullYear(), date2.getMonth(), date2.getDate());
    const diff = date2.getTime() - date1.getTime(); //目标时间减去当前时间
    const diffDate = diff / (24 * 3600 * 1000 ) -1; //计算当前时间与结束时间之间相差天数
    return Math.ceil(diffDate);
};
const AddEar = () => {
  http.get("MYroute/api/SheepFile/SheepFileConditionFinds?card=" + OustInfo.Earbugles)
  .then(res=>{
   // OustInfo.Earbugles = res.data.visualEarSignal;
    OustInfo.Breed = res.data.breed;
    OustInfo.Sex = res.data.sex;
    OustInfo.OustDorm = res.data.cottage;
    OustInfo.OustColumns = res.data.field;
    OustInfo.ReproductiveState = res.data.reproductiveState;   
  })
}

//添加弹出层初始值
const dialogTableVisible = ref(false);
//调用添加层
const OpenVisible = () => {
  addFormInfo();  
  OustInfo.OMId = 0;
  OustInfo.OustTime = "";
  OustInfo.SheepTypeId = 1;
  OustInfo.DocumentCord = "";
  dialogTableVisible.value = true;
}
//新增淘汰表单
const OustInfo = reactive({
  OMId:0,
  OustTime: "",
  Earbugles: "",
  OustCause: 0,
  Lingchatan: 0,
  Dispose:0,
  Breed: 0,
  Sex: 0,
  Reproductive: "",
  ReproductiveState: 0,
  OustMonth: 0,
  OustDay:0,
  OustDorm: "",
  OustColumns: "",
  ReviewBy:"",
  ReviewDate: "",
  UpdateBy: "",
  UpdateDate: "",
  CreateBy: "",
  CreateDate: "",
  DocumentCord: "",
  ExamineType:false,
  SheepTypeId:0,
  IsDel:false
});
const rowList = ref([]);
const NewUpdate = () => {
 rowList.value = [];
 dialogTableVisible.value = false;
}
//新增行表单
var newRow = {
  Earbugles: "",
  OustCause: 0,
  Lingchatan: 0,
  Dispose:0,
  Breed: 0,
  OustDorm: "",
  OustColumns: "",
}
//新增行
const rowLength = ref(0);
const addFormInfo = () => {
    OustInfo.Earbugles = "";
    OustInfo.OustCause = 0||null;
    OustInfo.Lingchatan = 0||null;
    OustInfo.Dispose = 0 || null;
    OustInfo.Breed = 0 || null;
    OustInfo.OustDorm = "";
    OustInfo.OustColumns = "";
    rowList.value.push(newRow);
    console.log(rowLength.value);
}
//对应出生状态
const statebirth=ref()
//对应出生状态下拉
const statebirthlist=()=>{
  http.get("MYroute/api/LamBing/GetinsertType").then(res=>{
    statebirth.value=res.data;
  })
}
//添加
const addOust = () => {
  if (OustInfo.OustTime == "") {    
      ElMessage({
          type: "error",
          message: "淘汰日期不能为空",
          duration: 2000
      })
    return;
  }
  if (OustInfo.DocumentCord == "") {    
      ElMessage({
          type: "error",
          message: "单据号不能为空",
          duration: 2000
      })
    return;
  }
  if (OustInfo.Earbugles == "") {
    
      ElMessage({
          type: "error",
          message: "耳号不能为空",
          duration: 2000
      })
    return;
  }
  if (OustInfo.OustCause == null) {    
      ElMessage({
          type: "error",
          message: "请选择淘汰原因",
          duration: 2000
      })
    return;
  }
  if (OustInfo.Lingchatan == null) {    
      ElMessage({
          type: "error",
          message: "请选择离场状态",
          duration: 2000
      })
    return;
  }
  if (OustInfo.Dispose == null) {    
      ElMessage({
          type: "error",
          message: "请选择离场状态",
          duration: 2000
      })
    return;
  }
  
  if (OustInfo.OMId == 0) {     
    OustInfo.OustDay = DateDiffer(new Date(OustInfo.OustTime));   
    http.post("first/api/Sheeponly/AddOustManage", OustInfo)
        .then(res => {
          if (res.data > 0) {
              ElMessage({
                  type: "success",
                  message: "保存成功",
                  duration: 2000
              })
              //更改档案的淘汰状态为已淘汰
              http.get("MYroute/api/SheepFile/SheepFileConditionFinds?card=" + OustInfo.Earbugles).then(res => {
                var form = res.data;
                form.presence = 5;
                statebirthlist();
                http.put("Mroute/api/SheepFile/SheepFileConditionUpdate", form)
              })
              dialogTableVisible.value = false;
              NewUpdate();
              GetOustInfo();
          } else if (res.data == -1) {
              ElMessage({
                  type: "error",
                  message: "保存失败，耳号不能重复",
                  duration: 2000
              })
          }
          else {
              ElMessage({
                  type: "error",
                  message: "保存失败",
                  duration: 2000
              })
          }
      })
  }
  else {
    OustInfo.OustDay = DateDiffer(new Date(OustInfo.OustTime));

    http.post("first/api/Sheeponly/UpdOustManage", OustInfo)
    .then(res => {
      if (res.data > 0) {
          ElMessage({
              type: "success",
              message: "保存成功",
              duration: 2000
          })
            //更改档案的淘汰状态为已淘汰
              http.get("MYroute/api/SheepFile/SheepFileConditionFinds?card=" + OustInfo.Earbugles).then(res => {
                  var form = res.data;
                  form.presence = 5;
                   statebirthlist();
                  http.put("Mroute/api/SheepFile/SheepFileConditionUpdate", form)
              })
          dialogTableVisible.value = false;
          NewUpdate();
          GetOustInfo();
      } else if (res.data == -1) {
          ElMessage({
              type: "error",
              message: "保存失败，耳号不能重复",
              duration: 2000
          })
      }
      else {
          ElMessage({
              type: "error",
              message: "保存失败",
              duration: 2000
          })
      }
  })
  }
  
}
//点击修改事件弹出层
const UpdInfo = (OMId: number | any) => {
  addFormInfo();
  if (OMId != 0) {
    http.get("srout/api/Sheeponly/EditOustManage?OMId="+OMId)
      .then(res => {
        OustInfo.OMId = res.data.OMId;
        OustInfo.OustTime = res.data.OustTime;
        OustInfo.Earbugles = res.data.Earbugles;
        OustInfo.OustCause = res.data.OustCause;
        OustInfo.Lingchatan = res.data.Lingchatan;
        OustInfo.Dispose = res.data.Dispose;
        OustInfo.Breed = res.data.Breed;
        OustInfo.Sex = res.data.Sex;
        OustInfo.Reproductive = res.data.Reproductive;
        OustInfo.OustMonth = res.data.OustMonth;
        OustInfo.OustDay = res.data.OustDay;
        OustInfo.OustDorm = res.data.OustDorm;
        OustInfo.OustColumns = res.data.OustColumns;
        OustInfo.ReviewBy = res.data.ReviewBy;
        OustInfo.ReviewDate = res.data.ReviewDate;
        OustInfo.UpdateBy = res.data.UpdateBy;
        OustInfo.UpdateDate = res.data.UpdateDate;
        OustInfo.CreateBy = res.data.CreateBy;
        OustInfo.CreateDate = res.data.CreateDate;
        OustInfo.DocumentCord = res.data.DocumentCord;
        OustInfo.SheepTypeId = res.data.SheepTypeId;
        OustInfo.ExamineType = res.data.ExamineType;
        GetField();
      })
      dialogTableVisible.value = true;
  }
}
//查询form
const form = reactive({
  eDate: "",
  sDate: "",
  Earbugles: "",
  OustCause: "" || null,
  Lingchatan: "" || null,
});
//淘汰管理列表
const OustManageList = ref([]);
const GetOustInfo = () => {
  http.get("srout/api/Sheeponly/GetOustManage", {
    params: {
      pageIndex: page.pageIndex,
      pageSize: page.pageSize,
      Edate: form.eDate,
      Sdate: form.sDate,
      Earbugles: form.Earbugles || null,
      OustCause: form.OustCause || null,
      Lingchatan: form.Lingchatan || null,
    }
  })
    .then(res => {
      OustManageList.value = res.data.datas;
      page.totalCount = res.data.totalCount;
      page.pageCount = res.data.pageCount;
    })
}
//分页属性
const page = {
  pageIndex: 1,
  pageSize: 10,
  pageCount: 0,
  totalCount: 0,
};
//总页数
const handleSizeChange = (val: number) => {
  page.pageSize = val;
  GetOustInfo();
};
//总条数
const handleCurrentChange = (val: number) => {
  page.pageIndex = val;
  GetOustInfo();
};
//选中数据
let ids = "";
const TagBool = ref(true);
const TagCount = ref(0);
const handleSelectionChange = (val: refs | any) => {
  refs.value = val;
  ids = "";
  val.forEach(x => {
    ids += x.OMId + ",";
  })
  ids = ids.substring(0, ids.length - 1);
  TagCount.value = ids.split(',').length;
  if (ids == "") {
    TagCount.value = 0;
  }
  if (TagCount.value == 0) {
    TagBool.value = true;
  }
  else {
    TagBool.value = false;
  }
}
//单个删除
const Del = (OMId: any) => {
  ElMessageBox.confirm("确定要此数据删除吗?", "提示", {
    confirmButtonText: "确认",
    cancelButtonText: "取消",
    type: "warning",
  })
    .then(() => {
      http
        .delete("first/api/Sheeponly/DelOustManage?OMId=" + OMId)
        .then((res) => {
          if (res.data > 0) {
            ElMessage({
              type: "success",
              message: "信息删除成功",
            });
            GetOustInfo();
          } else {
            ElMessage({
              type: "error",
              message: "信息删除失败",
            });
          }
        });
    })
    .catch(() => {
      ElMessage({
        type: "info",
        message: "Delete canceled",
      });
    });
};
//批量删除
const BatchDel = () => {
  let idss = refs.value.map(x => x.OMId);
  if (refs.value.length == 0) {
    ElMessage.error("至少选择一项");
    return;
  }
  ElMessageBox.confirm("确定要此数据删除吗?", "提示", {
    confirmButtonText: "确认",
    cancelButtonText: "取消",
    type: "warning",
  })
    .then(() => {
      http
        .post("first/api/Sheeponly/BatchOustManage?Array=" + idss)
        .then((res) => {
          if (res.data > 0) {
            ElMessage({
              type: "success",
              message: "信息批量删除成功",
            });
            GetOustInfo();
          } else {
            ElMessage({
              type: "error",
              message: "信息批量删除失败",
            });
          }
        });
    })
    .catch(() => {
      ElMessage({
        type: "info",
        message: "Delete canceled",
      });
    });
}
//审核通过
const BatchTrue = () => {
  let idss = refs.value.map(x => x.OMId);
  if (refs.value.length == 0) {
    ElMessage.error("至少选择一项");
    return;
  }
  ElMessageBox.confirm("确定要执行此操作吗?", "提示", {
    confirmButtonText: "确认",
    cancelButtonText: "取消",
    type: "warning",
  })
    .then(() => {
      http
        .post("first/api/Sheeponly/BatchTrueOustManage?Array=" + idss)
        .then((res) => {
          if (res.data > 0) {
            ElMessage({
              type: "success",
              message: "信息审核成功",
            });
            GetOustInfo();
          }
          else if (res.data == -1) {
            ElMessage({
              type: "error",
              message: "抱歉 选中的数据有误,请重新选择！",
            });
          }
          else {
            ElMessage({
              type: "error",
              message: "信息审核失败",
            });
          }
        });
    })
    .catch(() => {
      ElMessage({
        type: "info",
        message: "Delete canceled",
      });
    });
}
//重新审核
const BatchFalse = () => {
  let idss = refs.value.map(x => x.OMId);
  if (refs.value.length == 0) {
    ElMessage.error("至少选择一项");
    return;
  }
  ElMessageBox.confirm("确定要执行此操作吗?", "提示", {
    confirmButtonText: "确认",
    cancelButtonText: "取消",
    type: "warning",
  })
    .then(() => {
      http
        .post("first/api/Sheeponly/BatchFalseOustManage?Array=" + idss)
        .then((res) => {
          if (res.data > 0) {
            ElMessage({
              type: "success",
              message: "信息审核成功",
            });
            GetOustInfo();
          }
          else if (res.data == -1) {
            ElMessage({
              type: "error",
              message: "抱歉 选中的数据有误,请重新选择！",
            });
          }
          else {
            ElMessage({
              type: "error",
              message: "信息审核失败",
            });
          }
        });
    })
    .catch(() => {
      ElMessage({
        type: "info",
        message: "Delete canceled",
      });
    });
}
//淘汰原因
const OustCauseList = ref([
  {
    value: "",
    name: "",
  },
]);
//是否在场
const LingchatanList = ref([
  {
    value: "",
    name: "",
  },
]);
//品种下拉框
const BreedList = ref([
  {
    value: "",
    name: "",
  },
]);
//性别下拉框
const SexList = ref([
  {
    value: "",
    name: "",
  },
]);
//性别下拉框
const DisposeList = ref([
  {
    value: "",
    name: "",
  },
]);
//耳号
const ear = ref()
const GetOustList = () => {
  http.get("MYroute/api/SheepFile/SheepFileConditionEard").then(res => {
    ear.value = res.data;
  })
  http.get("srout/api/Sheeponly/GetOustCause").then((res) => {
    OustCauseList.value = res.data;
  });
  http.get("srout/api/Sheeponly/GetLingchatan").then((res) => {
    LingchatanList.value = res.data;
  });
  http.get("srout/api/Breeding/GetSex").then((res) => {
      SexList.value = res.data;
  });
  http.get("srout/api/Breeding/GetBreed").then((res) => {
      BreedList.value = res.data;
  });
  http.get("srout/api/Sheeponly/GetDispose").then((res) => {
      DisposeList.value = res.data;
  });
  
}
//栋舍集合
const Cottage = ref([]);
//栋舍下拉方法
const GetCooter = () => {
    http.get("OrganizationRead/api/Cottage/HandleGetCot").then(res => {
        Cottage.value = res.data;
    })
}
//栏位集合
const Field = ref([]);
//栏位下拉方法
const GetField = () => {
    http.get("OrganizationRead/api/Field/HandleGetSheepFarm?Id=" + OustInfo.OustDorm).then(res => {
        Field.value = res.data;
    })
}
onMounted(() => {
  GetOustInfo();
  GetOustList();
  GetCooter();
})

</script>
<style></style>